﻿@{
    ViewBag.Title = "Form"; 
    Layout = "~/Views/Shared/_Form.cshtml";
}
<script>
    layui.use(['jquery', 'form', 'laydate', 'common','optimizeSelectOption'], function () {
        var form = layui.form,
            $ = layui.$,
            common = layui.common,
            laydate = layui.laydate;
        var keyValue = $.request("keyValue");
               $('#F_UserId').val($.request("F_UserId"));
              $('#F_RealName').val(decodeURI($.request("F_RealName")));
             $('#F_UserNum').val(decodeURI($.request("F_UserNum")));
        //权限字段
        common.authorizeFields('adminform');
        //此处需修改
        //类型为时间时
        laydate.render({
                  elem: '#F_ProvidentDate'
                 , btns: ['clear', 'now']
                 , trigger: 'click',
                 format: 'yyyy-MM-dd',
             });
              laydate.render({
                  elem: '#F_InsuranceDate'
                 , btns: ['clear', 'now']
                 , trigger: 'click',
                 format: 'yyyy-MM-dd',
             });

        $(function () {
            initControl();
            if (!!keyValue) {
                 common.ajax({
                   url: '/SocialSecurityManagement/Insurance/GetFormJson',
                   dataType: 'json',
                   data: { keyValue: keyValue },
                   async: false,
                   success: function (data) {
                             data.F_ProvidentDate=="1900/01/01 00:00:00"?$("#F_ProvidentDate").val(""):  $("#F_ProvidentDate").val(util.toDateString(data.F_ProvidentDate, 'yyyy-MM-dd'));
                             data.F_InsuranceDate=="1900/01/01 00:00:00"?$("#F_InsuranceDate").val(""): $("#F_InsuranceDate").val(util.toDateString(data.F_InsuranceDate, 'yyyy-MM-dd'));

                        common.val('adminform', data);
                    }
               });
           }
           form.render();
       });
       wcLoading.close();

       function initControl() {
           //此处需修改
           //绑定数据源
           //类型为下拉框时
       }

       //监听提交
       form.on('submit(saveBtn)', function (data) {
           var postData = data.field;
           common.submitForm({
               url: '/SocialSecurityManagement/Insurance/SubmitForm?keyValue=' + keyValue,
               param: postData,
               success: function () {

                   common.parentreload('data-search-btn');
               }
           })
           return false;
       });
   });
     function search(fileds) {
          layui.use(['jquery', 'form', 'common'], function () {
              var form = layui.form,
                  $ = layui.$,
                  common = layui.common;
              //不同弹窗
                if (fileds == '人员') {
                    common.modalOpen({
                        title: "选择角色",
                            url: "/SystemOrganize/User/AddForm3?name=" + "F_RealName" + "&num="+"F_UserNum"+"&value=" + "F_UserId" + "&ids=" + $('#F_UserId').val(),
                        width: "650px",
                        height: "600px",
                    });
                 }
               else  if (fileds == '社保') {
                   common.modalOpen({
                       title: "选择项目",
                                 url: "/SocialSecurityManagement/InsuranceItems/AddForm?name=" + "F_InsuranceItemsName" + "&value=" + "F_InsuranceItems" + "&ids=" + $('#F_InsuranceItems').val(),
                       width: "650px",
                       height: "600px",
                   });
               }
                else  if (fileds == '公积金') {
                    common.modalOpen({
                        title: "选择项目",
                            url: "/SocialSecurityManagement/Providentitems/AddForm?name=" + "F_ProvidentItemsName" + "&value=" + "F_ProvidentItems" + "&ids=" + $('#F_ProvidentItems').val(),
                        width: "650px",
                        height: "600px",
                    });
                }
              else {
                  return false;
              }
          });
      }
</script>

<body>
    <div class="layuimini-container">
        <div class="layuimini-main">
            <div class="layui-form layuimini-form" lay-filter="adminform">

                <div class="layui-form-item layui-hide">
                    <label class="layui-form-label required">工号</label>
                    <div class="layui-input-block">
                        <input type="text" id="F_UserNum" name="F_UserNum" autocomplete="off" lay-verify="required" placeholder="请输入" class="layui-input" onclick="search('人员')">
                        <input id="F_UserId" name="F_UserId" type="text" hidden />
                    </div>
                </div>
                <div class="layui-form-item layui-hide">
                    <label class="layui-form-label required">姓名</label>
                    <div class="layui-input-block">


                        <input id="F_RealName" name="F_RealName" type="text" lay-verify="required" maxlength="50" autocomplete="off" class="layui-input" />
                    </div>
                </div>
               
             
                <div class="layui-form-item layui-hide">
                    <label class="layui-form-label ">大病金额</label>
                    <div class="layui-input-block">
                        <input type="text" id="F_Amountsick" name="F_Amountsick" autocomplete="off"  placeholder="请输入" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item layui-hide">
                    <label class="layui-form-label ">社保基数</label>
                    <div class="layui-input-block">
                        <input type="text" id="F_Amount" name="F_Amount" autocomplete="off"  placeholder="请输入" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item layui-hide">
                    <label class="layui-form-label ">社保项目</label>
                    <div class="layui-input-block">
                        <input id="F_InsuranceItemsName" name="F_InsuranceItemsName" placeholder="请输入内容" class="layui-textarea" onclick="search('社保')">
                        <input id="F_InsuranceItems" name="F_InsuranceItems" type="text" hidden />
                    </div>
                </div>
                <div class="layui-form-item layui-hide">
                    <label class="layui-form-label ">参保日期</label>
                    <div class="layui-input-block">
                        <input type="text" id="F_InsuranceDate" name="F_InsuranceDate" autocomplete="off"  placeholder="请输入" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item layui-hide">
                    <label class="layui-form-label ">公积金基数</label>
                    <div class="layui-input-block">
                        <input type="text" id="F_Amount1" name="F_Amount1" autocomplete="off"  placeholder="请输入" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item layui-hide">
                    <label class="layui-form-label ">公积金项目</label>
                    <div class="layui-input-block">
                        <input id="F_ProvidentItemsName" name="F_ProvidentItemsName" placeholder="请输入内容" class="layui-textarea" onclick="search('公积金')">
                        <input id="F_ProvidentItems" name="F_ProvidentItems" type="text" hidden />
                    </div>
                </div>
                <div class="layui-form-item layui-hide">
                    <label class="layui-form-label">参保日期</label>
                    <div class="layui-input-block">
                        <input type="text" id="F_ProvidentDate" name="F_ProvidentDate" autocomplete="off"  placeholder="请输入" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item layui-hide">
                    <button class="layui-btn site-demo-active" lay-submit id="submit" lay-filter="saveBtn">确认保存</button>
                </div>
            </div>
        </div>
    </div>
</body>

